package se3a04.mcmapster;

import android.widget.Button;
import android.os.Bundle;
import android.view.View;
import android.app.Activity;
import android.content.Intent;



public class CodeInputMenuControl extends Activity {
	@Override
	public void onCreate(Bundle savedInstanceState) 
	{
	        super.onCreate(savedInstanceState);
	        setContentView(R.layout.qrorentermenu);
	
	Button QRcode, Entercode;
	
	QRcode = (Button) findViewById (R.id.bScanQRCode);
	Entercode = (Button) findViewById (R.id.bEnterCode);
	
	QRcode.setOnClickListener(new View.OnClickListener(){
		public void onClick(View v){
			
			Intent intent = new Intent("com.google.zxing.client.android.SCAN");
			//intent.putExtra("SCAN_MODE", "QR_CODE_MODE");
			startActivityForResult(intent, 0);
		}
	});
	
	Entercode.setOnClickListener(new View.OnClickListener(){
		public void onClick(View v)
		{
			Intent intent = new Intent("se3a04.mcmapster.ENTERCODE");
			startActivity(intent);		
		}
	});
	}
	public String code; 
	public String codeformat;
	public void onActivityResult(int requestCode, int resultCode, Intent intent) {
		   if (requestCode == 0) {
		      if (resultCode == RESULT_OK) {
		         String contents = intent.getStringExtra("SCAN_RESULT");
		         String format = intent.getStringExtra("SCAN_RESULT_FORMAT");
		         code= contents;
		         codeformat = format;
		      } else if (resultCode == RESULT_CANCELED) {
		        finish();
		      }
		   }
		}

}